package com.tsystems.school.jabber.DataBase.Entities;

import com.sun.istack.internal.NotNull;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Kirill
 * Date: 22.08.11
 * Time: 13:46
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table( name = "Message" )
public class Message extends ManagedEntity{

	@ManyToOne
	@JoinColumn(name="conference_id")
	private Conference conf;

	@ManyToOne
	@JoinColumn(name="sender_id")
	private User sender;

	@Column(name="text")
	@NotNull
	private String text;

	public Message() {
	}

	public Conference getConf() {
		return conf;
	}

	public void setConf(Conference conf) {
		this.conf = conf;
	}

	public User getSender() {
		return sender;
	}

	public void setSender(User sender) {
		this.sender = sender;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@OneToMany(mappedBy = "confMessage")
	private Collection<PersonalMessage> personalMessages;

	public Collection<PersonalMessage> getPersonalMessages() {
		return personalMessages;
	}

	public void setPersonalMessages(Collection<PersonalMessage> personalMessages) {
		this.personalMessages = personalMessages;
	}
}
